<?php
namespace App\Http\Controllers\Xcx\Mall;


use App\Service\Xcx\Mall\OrderService;
use Illuminate\Http\Request;

class OrderController extends BaseController
{
    //商城订单

    //列表
    public function index(Request $request)
    {
        $type = $request->post('type', 0); //0全部，1待付款，2待发货，3待收货，4售后
        $pages['start'] = $request->post('page', 1);
        $pages['limit'] = $request->post('size', 5);
        $res = OrderService::getList($type, $pages);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data'], $res['total']);
    }

    //购物车下单
    public function addByCart(Request $request)
    {
        $uid = $request->post('uid', 0);
        $res = OrderService::addByCart($uid);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson();
    }
}